<?php
$this->headScript()
    ->appendFile($this->APP_STATIC_SERVER.'/js/jquery.cycle/jquery.cycle.all.min.js');
?>
<style>
    .cycle_nav a:hover, a:active{
        text-decoration:none;
    }
    .cycle_nav a{
        text-decoration:none;
    }
</style>
<div class="caption_box icon_title">
    <div style="float:left; width:50%">
        <span><?php echo $this->translator()->widget('enterprise_is_advertise');?></span>
    </div>
    <div style="float:right; width:50%;" class="cycle_nav">
        <div style="text-align:right; padding-right:5px; margin-top:-3px; font-size:20px;">
            <a id="ad_prev" href="#">«</a>&nbsp;<a id="ad_next" href="#">»</a>
        </div>
    </div>
</div>
<?php
    $skin_url = $this->APP_STATIC_SERVER . '/skins/'. $this->APP_TEMPLATE . '/'. $this->APP_SKIN;
?>
<div id="wid_advertise">
    <?php $i=0; foreach ($this->enterprises as $enterprise):?>
    <?php
        /**
        * Check image exist directory
        **/
        $file_noimage = $this->APP_STATIC_SERVER."/images/logos/no-logo.jpg";
        $file = $this->APP_STATIC_SERVER."/images/logos/".$enterprise->id.'.jpg';
        $path = str_replace($this->APP_STATIC_SERVER,getcwd(),$file);
        $urlImage = is_file($path)?$file:$file_noimage;

        /**
        * Param url detail
        **/
        $arrRouteDetail = array(
            'enterprise_id' => $enterprise->id,
            'enterprise_name' => Tomato_Utility_String::removeSign($enterprise->company_name_en, '-', true),
        );

        $enterprise_name = ($this->lang == 'vi_VN')?$enterprise->company_name_vn:$enterprise->company_name_en;

        /**
        * About us
        **/
        $info = $this->arrInfos[$enterprise->id];
    ?>

    <?php if($i%2==0):?>
    <div class="subrow" style="float:left;">
    <?php endif;?>
        <div class="<?php if($i%2==0):?>col_50l<?php else:?>col_50r<?php endif;?>">
            <div class="subcolumns_oldgecko">
                <a href="<?php echo $this->url($arrRouteDetail,'bizprofile_enterprise_index');?>"><span class="title"><?php echo $enterprise_name;?></span></a>
            </div>
            <div class="subcolumns_oldgecko" style="padding-bottom:5px;">
                <div class="geckol" style="padding-right:5px;">
                    <a href="<?php echo $this->url($arrRouteDetail,'bizprofile_enterprise_index');?>"><img class="item_img" width="95" src="<?php echo $urlImage;?>" /></a>
                </div>
                <div class="geckor">
                    <div style="text-align:justify">
                        <?php echo isset($info->info_string)?strip_tags(Tomato_Helper_Helper::substring($info->info_string, 300)):null;?>
                    </div>
                </div>
            </div>
        </div>
    <?php $i++; if($i%2==0):?>
    </div>
    <?php endif;?>
    <?php endforeach;?>
    <?php if($i%2!=0):?>
    </div>
    <?php endif;?>
</div>
<script type="text/javascript">
$(document).ready(function() {
    $('#wid_advertise').cycle({
        fx:     'scrollVert',
        timeout: 3000,
        delay:  1000,
        next:   '#ad_next',
        prev:   '#ad_prev',
    });

});
</script>